<template>
  <div>
    <el-table border :data="orderList" style="width: 100%">
      <el-table-column
        fixed
        prop="orderCode"
        label="订单编号"
        align="center"
        width="180"
      >
      </el-table-column>
      <el-table-column label="活动图片" align="center" width="180">
        <template slot-scope="scope">
          <el-image
          circle
          style="width: 50px; height: 50px"
            :src="scope.row.activity.activityUrl"
            :preview-src-list="previewSrcList"
            ></el-image>
        </template>
      </el-table-column>
      <el-table-column
        prop="user.nickname"
        label="用户昵称"
        align="center"
        width="180"
      >
      </el-table-column>
      <el-table-column
        prop="user.username"
        label="用户名"
        align="center"
        width="180"
      >
      </el-table-column>
      <el-table-column
        align="center"
        prop="activity.activityName"
        label="活动名称"
        width="180"
      >
      </el-table-column>
      <el-table-column prop="price" label="订单金额" align="center" width="180">
      </el-table-column>
      <el-table-column
        prop="gmtCreate"
        label="下单时间"
        align="center"
        width="180"
      >
      </el-table-column>
    </el-table>
    <el-pagination
      :current-page="current"
      :page-size="limit"
      :total="total"
      style="padding: 30px 0; text-align: center"
      layout="total, prev, pager, next, jumper"
      @current-change="init"
    />
  </div>
</template>

<script>
import order from "@/api/order";

export default {
  data() {
    return {
      orderList: [],
      previewSrcList: [],
      current: 1,
      limit: 6,
      total: 0,
    };
  },

  created() {
    this.init();
  },

  methods: {
    init(current = 1) {
      this.current = current;
      order.getOrderPageVo(this.current, this.limit, 0).then((res) => {
        this.previewSrcList = [];
        this.orderList = res.data.orderList;
        this.total = res.data.total;
        this.orderList.forEach((order) => {
          this.previewSrcList.push(order.activity.activityUrl);
        });
      });
    },
  },
};
</script>

<style scoped>
</style>